import { useConfigStore } from '@/store/index';
import request from '@/common/vmeitime-http';

//detail 收藏
export function collectAPI(id) {
  return request.request({
    url: `/product/mall/v2/api/like/${id}`,
    method: 'post'
  })
}


//发表楼盘评论
export function submitComment(params) {
  return request.request({
    url: `/product/mall/cm/api/reply`,
    method: 'post',
    data: params
  })
}

//创建楼盘评论
export function createComment(params) {
  return request.request({
    url: `/product/mall/cm/api/create`,
    method: 'post',
    data: params
  })
}

//获得楼盘评论
// export function getCommentForProduct(id){
//   return request.request({
//     url: `/product/mall/api/comment/product?product_id=${id}`
//   })
// }

//回答问题
export function submitQuestionReply(id, params) {
  return request.request({
    url: `/product/mall/qa/api/${id}`,
    method: 'post',
    data: params
  })
}

//获得用户头像
export function getUserImageUrl() {
  return request.request({
    url: `/account/mall/api/image`,
  })
}

//获得用户unionid
export function getUserUnionid(type) {
  return request.request({
    url: `/account/mall/api/unionid?type=${type}`,
  })
}

//设置推荐条件
export function submitRecommend(params) {
  return request.request({
    url: `/account/mall/api/recommend`,
    method: 'post',
    data: params
  })
}

//获得搜索条件信息
export function getSearchInfo() {
  return request.request({
    url: `/public/api/search/info`,
  })
}

//获得指定城市的地铁
export function getSubway(city) {
  return request.request({
    url: `/public/api/v2/subway?city=${city}`,
  })
}

//获得指定城市的地铁
export function getSubwayHouseCount(params) {
  return request.request({
    url: `/product/mall/api/subway`,
    data: params
  })
}

//获得楼盘简单信息
export function getPkProduct(id) {
  return request.request({
    url: `/product/mall/pk/api/info/${id}`
  })
}

//获得楼盘简单信息
export function getPkProductSingle(id) {
  return request.request({
    url: `/product/mall/pk/api/pk/single/${id}`
  })
}

//创建浏览记录
export function createHistory(info) {
  return request.request({
    url: `/product/mall/v6/history`,
    method: 'post',
    data: {
      product: info.id,
      keywords: info.keywords || ""
    }
  })
}

//认筹检测详情列表
export function getRenChouDetail(id) {
  return request.request({
    url: `/product/mall/api/chips/${id}`
  })
}

//获取二手房楼盘详情
export function getSecondHouseDetail(product_id) {
  return request.request({
    url: `/sechouse/mall/v2/api/community/${product_id}`,
    method: 'get'
  })
}

//获取二手房订阅
export function getSecondSub(params) {
  return request.request({
    url: `/sechouse/mall/api/community/subscribe/info`,
    method: 'get',
    data: params
  })
}

/**
 * 订阅楼盘
 * @param {String} phone 手机号
 * @param {Number} productId 楼盘ID
 * @param {Boolean} shouquan 是否授权 
*/
export function doSubscribe(data) {
  return request.request({
    url: `/product/mall/v5/subscribe/${data.productId}`,
    method: 'post',
    data
  })
}

//取消新房订阅
export function unSubscribe(id) {
  return request.request({
    url: `/product/mall/api/subscribe/${id}`,
    method: 'post'
  })
}

//取消二手房订阅
export function unSubscribeSecond(id) {
  return request.request({
    url: `/sechouse/mall/v2/api/subscribe`,
    method: 'post',
    data: { 'product_id': id }
  })
}

//获取小胖君二维码
export function getQrcode(cityCode) {
  return request.request({
    url: `/public/api/qrcode?city=${cityCode}`
  })
}

//二手房订阅
export function subscribeAssistantAPI(params) {
  return request.request({
    url: `/sechouse/mall/v2/api/subscribe`,
    method: 'post',
    data: params
  })
}

//提交用户手机号
export function postContactPhone(params) {
  return request.request({
    url: `/account/mall/api/contact`,
    method: 'post',
    data: params
  })
}

//获取二手房订阅列表
export function getSubSecondHouse(url) {
  return request.request({
    url,
    method: 'get',
  })
}

/**
 * 提交看房报名
 * @param name {String}
 * @param phone {String}
 * @param source {Number} 0小程序平台; 1公众号，2方便看房
 */
export function signUpHouse(info) {
  return request.request({
    url: `/product/mall/v6/check/${info.id}`,
    method: 'post',
    data: {
      name: info.name,
      phone: info.phone,
      source: 0
    }
  })
}

//删除指定卖房信息
export function deleteSellingHouse(id) {
  return request.request({
    url: `/product/mall/api/sell/${id}`,
    method: 'delete',
  })
}

//设置推送楼盘
export function pushHouseMsg(type) {
  return request.request({
    url: '/account/mall/api/push',
    method: type
  })
}

//获得样板间图片列表
export function getProductTemplateList(id) {
  return request.request({
    url: `/product/mall/api/template/${id}`,
    method: 'get'
  })
}

//获得日照分析图片列表
export function getSunshineList(kaiId) {
  return request.request({
    url: `/product/mall/v6/pan/sun/${kaiId}`
  })
}

//获取某开盘批次噪音分析列表
export function getNoiseList(kaiId) {
  return request.request({
    url: `/product/mall/v6/pan/noise/${kaiId}`
  })
}

export function getProductVRList(kaiId) {
  return request.request({
    url: `/product/mall/v6/pan/vr/${kaiId}`
  })
}

//获取航拍列表
export function getprodAerialList(kaiId) {
  return request.request({
    url: `/product/mall/v6/pan/fly/${kaiId}`
  })
}

//获取开盘视频列表
export function getKaiVideoList(kaiId) {
  return request.request({
    url: `/product/mall/v6/pan/video/${kaiId}`
  })
}

//获取租房初始化数据
export function getTenementHouseData(cityCode) {
  return request.request({
    url: `/sechouse/mall/rent/info?city=${cityCode}`,
    method: 'get'
  })
}

//获取法拍房初始化数据
export function getFapaiHouseData(cityCode) {
  return request.request({
    url: `/sechouse/mall/law/info?city=${cityCode}`,
    method: 'get'
  })
}

//获取视频的真正播放地址
export function getVideoUrl(vid) {
  return request.request({
    url: `https://h5vv6.video.qq.com/getinfo?defn=auto&platform=4210801&otype=json&sdtfrom=v4169&appVer=7&vid=${vid}&newnettype=1`,
    method: 'get'
  })
}

//视频播放页面请求
export function playVideoAPI(vid) {
  return request.request({
    url: `/product/mall/v3/api/video/${vid}`,
    method: 'get'
  })
}


//猜你喜欢
export function getGuessHouses(url) {
  return request.request({
    url
  })
}

//手机号授权解密
export function decryptPhoneApi(info) {
  return request.request({
    url: `/account/mall/api/phone`,
    method: 'post',
    data: info
  })
}

//获取一房一价表
export function priceTableAPI(kaiId) {
  return request.request({
    url: `/product/mall/v6/pan/houseprice/${kaiId}`
  })
}

//获取有无最新消息
export function newMsgAPI() {
  return request.request({
    url: `/product/mall/v3/api/notify/count`,
    method: 'get'
  })
}

//消息全部已读
export function readMsgAPI() {
  return request.request({
    url: `/product/mall/v3/api/notify/read`,
    method: 'post'
  })
}

/**
 * @desc 顾问入驻上传参数params
 * @param type {String} seller
 * */
export function uploadParamsAPI(type = '') {
  return request.request({
    url: `/public/api/params?type=${type}`
  })
}

//上传图片识别params
export function uploadDistParams() {
  return request.request({
    url: `/seller/mall/image`
  })
}

//意见反馈
export function postFeedBack(data) {
  return request.request({
    url: `/account/mall/api/feedback`,
    method: 'post',
    data: data
  })
}

//多楼盘评分PK
export function getGradePkAPI(infos) {
  return request.request({
    url: `/product/mall/pk/api/v3/simple?simple=${infos.type}&id=${infos.ids}`,
    method: 'get'
  })
}

//多楼盘评分PK
export function getGradePkAPICustom(ids) {
  return request.request({
    url: `/product/mall/pk/api/v3/custom?id=${ids}`,
    method: 'get'
  })
}

//摇号查询
export function lotterySearch(info) {
  return request.request({
    url: `/product/mall/api/yao/${info.id}?code=${info.keyword}`,
    method: 'get'
  })
}

//摇号日历
// export function calendarHouses(info){
// 	return request.request({
// 		url: `/product/mall/v4/api/history?city=${info.city}&year=${info.year}&month=${info.month}`,
// 		method: 'get'
// 	})
// }

//搜索小区
export function getVillages(data) {
  return request.request({
    url: `/product/mall/sell/api/community/query?title=${data}`,
    method: 'get',
  })
}

//提交二手房创建/修改
export function createVillage(data) {
  return request.request({
    url: data.setting ? `/product/mall/sell/api/address/${data.id}` : `/product/mall/sell/api/create`,
    method: data.setting ? 'put' : 'post',
    data
  })
}

//获取二手房信息
export function getSecHouse(id) {
  return request.request({
    url: `/product/mall/sell/api/address/${id}`,
    method: 'get',
  })
}

//二手房图片修改和获取
export function secHouseImgAPI(data) {
  return request.request({
    url: `/product/mall/sell/api/image/${data.id}`,
    method: data.put ? 'put' : 'get',
    data: data.put ? data : ''
  })
}

//二手房信息获取、修改
export function secHouseMsgAPI(data) {
  return request.request({
    url: `/product/mall/sell/api/info/${data.id}`,
    method: data.put ? 'put' : 'get',
    data: data.put ? data : ''
  })
}

//二手房介绍获取、修改
export function secHouseDescAPI(data) {
  return request.request({
    url: `/product/mall/sell/api/desc/${data.id}`,
    method: data.put ? 'put' : 'get',
    data: data.put ? data : ''
  })
}

//提交购房积分
export function postSocialStatis(data) {
  return request.request({
    url: `/account/mall/api/chou/points`,
    method: 'post',
    data: data
  })
}

//获取购房积分统计
export function socialStatisticsAPI() {
  return request.request({
    url: `/account/mall/api/chou/points`,
    method: 'get',
  })
}

//图片识别信息
export function distinguishMsg(data) {
  return request.request({
    url: `/seller/mall/image`,
    method: 'post',
    data
  })
}
//置业顾问信息提交
export function adviserMsgSubmit(data, type, id) {
  return request.request({
    url: type == 'post' ? `/seller/mall/create` : `/seller/mall/detail/${id}`,
    method: type == 'post' ? 'post' : 'put',
    data
  })
}

//查询置业顾问审核状态
export function adviserExamine() {
  return request.request({
    url: `/seller/mall/check`,
    method: 'get'
  })
}

//获取置业顾问提交数据
export function adviserFormData(id) {
  return request.request({
    url: `/seller/mall/detail/${id}`,
    method: 'get'
  })
}


//搜索楼盘排行榜列表数据
export function searchPanelAPI(city) {
  return request.request({
    url: `/product/mall/v4/api/search/top?city=${city}`,
    method: 'get'
  })
}

//搜索楼盘
export function selectHouseAPI(info) {
  return request.request({
    url: `/product/mall/v4/api/search/imm?city=${info.city}&key=${info.keyword}`,
    method: 'get'
  })
}

/**
 * 搜索500万级置业楼盘列表
 * 
*/
export function searchMillionsProducts(info) {
  return request.request({
    url: `/product/im/card/amount?city=${info.city}&key=${info.keyword}`,
  })
}

/**
 * 根据ID获取指定楼盘详情
 * @param {string} id 楼盘ID
*/
export function getProdDetailById(id) {
  return request.request({
    url: `/product/im/card/${id}`
  })
}

//楼盘动态
export function houseDynamicAPI(id) {
  return request.request({
    url: `/product/mall/v5/change/${id}`,
    method: 'get'
  })
}

//楼盘详情
export function houseDeatilMsg(id) {
  return request.request({
    url: `/product/mall/v5/base/${id}`,
    method: 'get'
  })
}

//楼盘相册
export function houseAlbumAPI(id) {
  return request.request({
    url: `/product/mall/v5/image/${id}`,
    method: 'get'
  })
}

//历史开盘
export function historyKai(id) {
  return request.request({
    url: `/product/mall/v5/pan/history/${id}`,
    method: 'get'
  })
}

//楼盘榜单
export function housesRankingAPI(info) {
  return request.request({
    url: `/product/mall/v6/bang?city_code=${info.cityCode}&area_code=${info.areaCode}&bang_type=${info.type}`,
    method: 'get'
  })
}

/**
 * 根据cityCode获取区域
 * @param {String} cityCode
 * @param {Number} huanXian: 1、0
*/
export function getAreaAPI(cityCode, huanXian = 0) {
  return request.request({
    url: `/public/api/city?city=${cityCode}&huan=${huanXian}`,
    method: 'get'
  })
}

//评论点赞
export function commentThumbApi(id) {
  return request.request({
    url: `/product/mall/cm/api/love/${id}`,
    method: 'post'
  })
}

//楼盘某个评论详情
export function commentDetail(id) {
  return request.request({
    url: `/product/mall/cm/api/detail/${id}`,
  })
}

//置业顾问列表
export function adviserList(info) {
  return request.request({
    url: `/seller/mall/list?product_id=${info.id}&city=${info.cityCode}`,
  })
}

//置业顾问详情
export function adviserDetailAPI(id) {
  return request.request({
    url: `/seller/mall/index/${id}`,
  })
}

//置业顾问历史记录
export function adviserHistoryAPI(id) {
  return request.request({
    url: `/seller/mall/history/${id}`,
    method: 'post'
  })
}

//置业顾问选择楼盘
export function adviserSearchHouse(info) {
  return request.request({
    url: `/seller/mall/select?title=${info.keyword}&city=${info.cityCode}`,
  })
}

//置业顾问创建动态
export function adviserPublishDynamic(data) {
  return request.request({
    url: `/seller/mall/news/create`,
    method: 'post',
    data
  })
}

//置业顾问点赞
export function adviserThumb(id) {
  return request.request({
    url: `/seller/mall/love/${id}`,
    method: 'post'
  })
}

//置业顾问删除动态
export function adviserRemoveDynamic(id) {
  return request.request({
    url: `/seller/mall/news/detail/${id}`,
    method: 'delete'
  })
}

//购房流程
export function purchaseWiki(cityCode) {
  return request.request({
    url: `/product/mall/v5/rule?city=${cityCode}`
  })
}

//摇号结果
export function yaoResults(kaiId) {
  return request.request({
    url: `/product/mall/v6/pan/yao/${kaiId}`
  })
}

//认购规则
export function renGouRules(kaiId) {
  return request.request({
    url: `/product/mall/v6/pan/rules/${kaiId}`
  })
}

//获取验证码
export function getVerificationCode(info) {
  return request.request({
    url: `/account/mall/api/sms`,
    method: 'post',
    data: info
  })
}

//登录
export function loginAPI(info) {
  const configStore = useConfigStore();

  return request.request({
    url: `/account/mall/api/login`,
    method: 'post',
    data: {
      ...info,
      version: configStore.version
    }
  })
}

//验证该用户是否授权过手机号
export function checkUserAuthPhone() {
  return request.request({
    url: `/account/mall/api/phone`
  })
}

//二手房核验价格热门接口、
export function secondHouseHeYanHot(info) {
  return request.request({
    url: `/sechouse/mall/v2/api/hot/community`,
  })
}

//投票获取
export function getVoteList(id) {
  return request.request({
    url: `/ticket/mall/detail/${id}`,
  })
}

/**
 * 投票提交
 * @param ticked_id {Array} 投票ID
 * @param choice_list {Array} 选项ID
*/
export function doVote(data) {
  return request.request({
    url: `/ticket/mall/choice/submit`,
    method: 'post',
    data
  })
}

//找房页面板块分类
export function findPageAPI(city) {
  return request.request({
    url: `/product/mall/v6/class?city=${city}`
  })
}

//榜单价格段获取
export function getPriceRange(city, type = '') {
  return request.request({
    url: `/product/mall/v6/price/range?city=${city}&type=${type}`
  })
}

//环线找房navs
export function getHuanxianNavs(city) {
  return request.request({
    url: `/product/mall/v6/line?city=${city}`
  })
}

//板块找房navs
export function getPlateNavs(city) {
  return request.request({
    url: `/product/mall/v6/class/all?city=${city}`
  })
}

//入围分数
export function ruweiFraction(kaiId) {
  return request.request({
    url: `/product/mall/v6/pan/points/${kaiId}`
  })
}

//今日取证公示list
export function quzhengList(cityCode) {
  return request.request({
    url: `/product/mall/v6/gong/list?city=${cityCode}`
  })
}

//取证公示详情
export function quzhengDetail(id) {
  return request.request({
    url: `/product/mall/v6/gong/${id}`
  })
}

/**
 * 获取开盘信息
 * @param {String} kaiId 开盘ID
 * @param {String} version 用户最新的加密通道version
*/
export function kaiPanAPI(info) {
  return request.request({
    url: `/product/mall/v6/pan/${info.kaiId}`
  })
}

//获取楼盘的所有开盘id
export function panListAPI(id) {
  return request.request({
    url: `/product/mall/v6/pan/title/${id}`
  })
}

//获取某一开盘id的户型图
export function panHouseTypeAPI(kaiId) {
  return request.request({
    url: `/product/mall/v6/pan/size/${kaiId}`
  })
}

//地图周边API
export function mapNerbaySearch(info) {
  return request.request({
    url: `/product/mall/v6/around/${info.productId}?key=${info.keyword}`
  })
}

/**
 * 一房一价
 * @param {String} kaiId 开盘ID
 * @param {String} version 用户最新的加密通道version
*/
export function kaiOneHousePrice(info) {
  return request.request({
    url: `/product/mall/v6/pan/room/${info.kaiId}?v=${info.version}`
  })
}

//小胖快讯点击分型+1
export function expressNewsShareAPI(id) {
  return request.request({
    url: `/product/mall/v6/tips/share/${id}`,
    method: 'post'
  })
}

/**
 * 粉丝卖房默认参数获取
 * 装修、朝向、产权、省份
 */
export function fansHousesParams() {
  return request.request({
    url: `/product/mall/sell/api/params`
  })
}

/**
 * 粉丝房源详情
 */
export function fansHouseAPI(productId) {
  return request.request({
    url: `/product/mall/sell/api/detail/${productId}`
  })
}

/**
 * 首页和详情页广告点击率
 */
export function ADStatistics(data) {
  return request.request({
    url: `/statistics/mall/push`,
    method: 'post',
    data
  })
}

/**
 * 公共get请求
 */
export function baseGetRequest(url) {
  return request.request({
    url
  })
}
